import {ServicePrefixEnum} from "@/enums/commonEnum";
import {RequestEnum} from "@/enums/httpEnum";
import {defHttp} from "@/utils/http/axios";
import type { AxiosRequestConfig } from 'axios';
import request from '@/config/axios'

export type DictTypeVO = {
  id: number | undefined
  name: string
  type: string
  status: number
  remark: string
  createTime: Date
}
const  MODULAR = '/system/dict-type'
export const Api = {
  GetSimpleDictTypeList: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/list-all-simple`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetDictTypePage: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetDictType: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  CreateDictType: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/create`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  UpdateDictType: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  DeleteDictType: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/delete`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,

}
// 查询字典（精简)列表
export const getSimpleDictTypeList = () => {
  return defHttp.request({ ...Api.GetSimpleDictTypeList })
}

// 查询字典列表
export const getDictTypePage = (params: PageParam) => {
  return defHttp.request({ ...Api.GetDictTypePage,params: params })
}

// 查询字典详情
export const getDictType = (id: number) => {
  let params = { id: id }
  return defHttp.request({ ...Api.GetDictType,params: params })
}

// 新增字典
export const createDictType = (data: DictTypeVO) => {
  let params = {data: data}
  return defHttp .request({ ...Api.CreateDictType,params:params })
}

// 修改字典
export const updateDictType= (data: DictTypeVO) => {
  let params = {data: data}
  return defHttp .request({ ...Api.UpdateDictType,params:params })
}

// 删除字典
export const deleteDictType = (id: number) => {
  let params = { id: id }
  return defHttp .request({ ...Api.DeleteDictType,params:params })
}
// 导出字典类型
//TODO
export const exportDictType = (params) => {
  return request.download({ url: '/system/dict-type/export', params })
}
